Skip to content

test(maths): strengthen armstrongNumber tests against mutation (R50-T050) - #98

Open
aniruddha-bongale wants to merge 1 commit into
S-AI-Projects:masterfrom
aniruddha-bongale:student/e26b07f0827/R50-T050
Open

aniruddha-bongale wants to merge 1 commit into
S-AI-Projects:masterfrom
aniruddha-bongale:student/e26b07f0827/R50-T050

Conversation

@aniruddha-bongale

Copy link
Copy Markdown

Description

Strengthen unit test coverage for armstrongNumber in Maths/ArmstrongNumber.js to build a mutation-resistant regression test suite. Prove that the regression tests detect plausible one-line mistakes (such as off-by-one boundary errors rejecting the smallest valid input 0 and hardcoded cube power mutations failing multi-digit Armstrong numbers like 1634) while preserving documented public behavior. Provide an automated check runner work/R50-T050/check.py saving verification results to work/R50-T050/results.json.

Related Issue

Fixes: #50

Type of Change

  • Documentation update
  • Tests (adding missing tests or fixing existing tests)

Changes Made

  • Added comprehensive JSDoc documentation to Maths/ArmstrongNumber.js identifying protected semantic conditions and preconditions:
    • Line 24: Boundary guard num < 0 permits the smallest valid input 0 ($0^1 = 0$), protecting against an off-by-one mutation num <= 0.
    • Line 27: Dynamic exponentiation ** numStr.length dynamically scales with digit count, protecting against hardcoded cube mutations (** 3) for 4-digit Armstrong numbers (e.g. 1634).
  • Added regression tests in Maths/test/ArmstrongNumber.test.js:
    • Smallest valid input 0 and single-digit numbers 1, 5, 9.
    • Ordinary 3-digit Armstrong numbers (370, 371, 153, 407).
    • Multi-digit Armstrong numbers (1634, 8208).
    • Ordinary non-Armstrong numbers (10, 100, 1633).
    • Negative values and non-number types.
  • Implemented work/R50-T050/check.py executing native tests, validating original behavior against all fixtures, and demonstrating that deliberate one-line mutants fail the named assertions for semantic reasons while the original passes.

Screenshots / Recordings

All 9 unit tests for ArmstrongNumber passed cleanly. Both mutant detection proofs passed.

Testing

  • Ran npm test -- Maths/test/ArmstrongNumber.test.js - all 9 tests passed.
  • Executed python3 work/R50-T050/check.py - original assertions verified and mutants caught.
  • Confirmed Prettier code style check passes.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

Student: Aniruddha Bongale (Enrollment: E26B07F0827)
Task ID: R50-T050

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aniruddha Bongale — R50-T050: Strengthen the tests of armstrongNumber (ArmstrongNumber.js) [Maths/ArmstrongNumber.js]

1 participant